Skip to content

fix:/prefer the use of column identity over ordinals#4211

Open
johnbrk wants to merge 2 commits intolaunchbadge:mainfrom
johnbrk:fix/column-ordinality-mismatch
Open

fix:/prefer the use of column identity over ordinals#4211
johnbrk wants to merge 2 commits intolaunchbadge:mainfrom
johnbrk:fix/column-ordinality-mismatch

Conversation

@johnbrk
Copy link
Copy Markdown

@johnbrk johnbrk commented Mar 31, 2026

Does your PR solve an issue?

Fixes #4210

Is this a breaking change?

No, just makes query_as! behave more like query_as

Copy link
Copy Markdown
Contributor

@barry3406 barry3406 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch — the ordinal-vs-name mismatch in query_as! has bitten a few people.

One thing I noticed: this only switches to column-name lookup for the (true, ColumnType::Exact) branch, but the Wildcard, OptWildcard, and (false, _) arms still use #i (the ordinal). If the column order can differ at runtime (the exact scenario in #4210), those branches would still break. Was that intentional, or should they also use stringify!(#column_ident)?

Also minor: quote::format_ident!("{}", ident) is a no-op when ident is already an Ident — you can pass &ident directly into the quote! interpolation and stringify!(#ident) will work the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MySQL: query_as macro deserializes a row based on column ordinality instead of column identity

2 participants